﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Jenkins.Domain.Tests
{
    using Ploeh.AutoFixture;

    [TestClass]
    public class JenkinsJobStatusTests
    {
        private readonly Fixture defaultFixture = new Fixture();

        [TestMethod]
        public void Invoke_Equals_OnDifferentReferences_WithSameAttributes_ShouldReturnTrue()
        {
            var isRunning = defaultFixture.Create<bool>();
            var state = defaultFixture.Create<JenkinsJobState>();

            var status1 = new JenkinsJobStatus() {  IsRunning = isRunning, State = state };
            var status2 = new JenkinsJobStatus() {  IsRunning = isRunning, State = state };

            Assert.AreEqual(status1, status2);
        }

        [TestMethod]
        public void Invoke_Equals_OnDifferentReferences_WithDifferentRunning_ShouldReturnFalse()
        {
            var isRunning = defaultFixture.Create<bool>();
            var state = defaultFixture.Create<JenkinsJobState>();

            var status1 = new JenkinsJobStatus() { IsRunning = isRunning, State = state };
            var status2 = new JenkinsJobStatus() { IsRunning = !isRunning, State = state };

            Assert.AreNotEqual(status1, status2);
        }

        [TestMethod]
        public void Invoke_Equals_OnDifferentReferences_WithDifferentState_ShouldReturnFalse()
        {
            var isRunning = defaultFixture.Create<bool>();
            var state = defaultFixture.Create<JenkinsJobState>();
            var state2 = (JenkinsJobState)((((int)state) + 1) % 6);

            var status1 = new JenkinsJobStatus() { IsRunning = isRunning, State = state };
            var status2 = new JenkinsJobStatus() { IsRunning = isRunning, State = state2 };

            Assert.AreNotEqual(status1, status2);
        }

        [TestMethod]
        public void Invoke_Equals_OnSameReferences_ShouldReturnTrue()
        {
            var isRunning = defaultFixture.Create<bool>();
            var state = defaultFixture.Create<JenkinsJobState>();

            var status1 = new JenkinsJobStatus() { IsRunning = isRunning, State = state };
            var status2 = status1;

            Assert.AreEqual(status1, status2);
        }
    }
}
